<?php

header('content-type:text/html;charset:utf-8');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:GET,POST,PUT');
header('Access-Control-Allow-Headers:x-requested-with,content-type');

require_once 'db.php';
require_once 'response.php';
//require_once './upload.fun.php';
//require_once 'common.func.php';

//if($_GET) {
//    exit('die');
//}



//$test = isset($_POST['content']) ? $_POST['content'] : '';
$test = isset($_GET['give']) ? $_GET['give'] : '';

if(empty($test)){
    die('shut down');
}

try{
    $connect = Db::getInstance()->connect();
}catch (Exception $e) {
    return Response::show(403,'数据库连接失败',$e->getMessage());
}


//$sql = "INSERT report VALUES(null,'test','{$test}','test','test','test','admin',1,0)";

$sql = "SELECT program_content FROM report WHERE report_id=11";
$res = $connect->query($sql);

//var_dump($res);
//echo $connect->insert_id;

if($res && $res->num_rows>0) {
    $data = $res->fetch_assoc();
//    var_dump($data);
}

    return Response::show(200,'数据获取成功',$data);

//var_dump($_POST);
exit();
$files = getFiles();

foreach ($files as $fileInfo) {
    $res = uploadFile($fileInfo);
    echo $res['mes'],'<br/>';
    $mes[] = $res['mes'];
    $uploadFiles[] = @$res['dest'];
}
//array_values() 函数返回一个包含给定数组中所有键值的数组，
//但不保留键名，被返回的数组将使用数值键，从 0 开始并以 1 递增
$uploadFiles = array_values(array_filter($uploadFiles));
print_r($uploadFiles);

print_r($mes);